package com.szholly.pro.watergas_server.ps.android.common;

/**
 * 生成不重复的连续数字，可以作为后缀。
 * 
 * 2017/3/23 <br/>
 *
 * @author Joey Huang QQ:273179370）
 */
public class SuffixCreator {
	public static final SuffixCreator DEFAULT_THREE = new SuffixCreator(3);	
	
	private int length;
	private int currNumber;
	private int maxNumber;
	
	public SuffixCreator(int length) {		
		this.length = length;
		if (length <=0) {
			throw new IllegalArgumentException("length can not <= 0");
		}
		maxNumber = (int) Math.pow(10, length);
	}

	public String createNumberString(){
		currNumber++;
		currNumber = currNumber >= maxNumber ? 0 : currNumber;
		return String.format("%0"+length+"d", currNumber);
	}	
}
